package com.ikun.starters.jwt;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author ximeng
 * @title: ITokenService
 */
public interface ITokenService {
    /**
     * 生成token
     *
     * @param userId
     * @param username
     * @param subject
     * @return
     */
    String createToken(String userId, String username, Map<String, Object> subject);

    /**
     * 校验token
     *
     * @param token
     * @return
     */
    Boolean verifyToken(String token);


    /**
     * 刷新Token
     * @param token
     * @return
     */
    String refreshToken(String token);

    /**
     * 从请求中获取token
     * @param req
     * @param tokenName
     * @return
     */
    String getToken(HttpServletRequest req, String tokenName);
}
